package com.gpscookie.redpanic;

import android.graphics.Canvas;
import android.graphics.Color;

public class BombDot extends RedDot {
	private float exploderadius = 0;	
	private int color;
	
	public BombDot(float beginx, float beginy) {
		super(beginx, beginy);
		color = 139; 
		paint.setColor(Color.rgb(46, color, 87));
		radius = 10;
	}
	
	@Override 
	public boolean isOverlapped(Entity other) {
		float left = (radius + other.radius);
		left = left*left;
		float right = (x-other.x)*(x-other.x)+(y-other.y)*(y-other.y);
		return right<left;
	}
	
	@Override
	public void draw(Canvas canvas) {
		if (exploderadius==radius) {
			live = false;
		} else if (exploderadius>radius) {
			radius++;
			color += 10;
			paint.setColor(Color.rgb(46, color, 87));
			canvas.drawCircle(x, y, radius, paint);
			//canvas.drawRect(x, y, x+width, y+height, paint);
		} else {
			canvas.drawCircle(x, y, radius, paint);
			//canvas.drawRect(x, y, x+width, y+height, paint);
		}
	}
	
	public boolean isExploding() {
		if (exploderadius>radius) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public void explode() {
		if (exploderadius>0) {
			// already exploded
			return;
		}
		exploderadius = radius*5;
		width = exploderadius*2;
		height = width;

	}
}
